<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of commandes_m
 *
 * @author Gidaff_01
 */
class Transport_m extends Model {

    //put your code here
    function Transport_m() {
        parent::Model();
        $this->load->database();
    }

    function get_all_transport($per_page, $offset) {
        $this->db->select();
        $this->db->from('zoo_transporteur');
          $this->db->order_by('id', 'DESC');
        $this->db->limit($per_page, $offset);
        $query = $this->db->get();
        return $query->result_array();
    }
     function update_transport($data,$id){
        return $this->db->update('zoo_transporteur',$data,array('id' => $id));
    }


    function get_transport_by_id($id){
        $this->db->select();
        $this->db->from('zoo_transporteur');
        $this->db->where('id', $id);
        $query = $this->db->get();
        return $query;
    }
     function add_transport($data){
        return $this->db->insert('zoo_transporteur',$data);
    }
     function delete_transport($id){
        $this->db->delete('zoo_tarif',array('id_transporteur'=>$id));
        return $this->db->delete('zoo_transporteur', array('id' => $id));
    }
    function get_tarif_transport($id,$per_page,$off_set){
        $this->db->select();
        $this->db->from('zoo_tarif');
        $this->db->where('id_transporteur', $id);
        $this->db->order_by('min', 'ASC');
        $this->db->limit($per_page,$off_set);
        $query = $this->db->get();
        return $query->result_array();
    }
    function add_tarif($data){
        return $this->db->insert('zoo_tarif',$data);
    }
    function delete_tarif($id){
        return $this->db->delete('zoo_tarif',array('id'=>$id));
    }
    function count_tarif($id){
        $this->db->select();
        $this->db->from('zoo_tarif');
        $this->db->where('id_transporteur', $id);
        $this->db->order_by('min', 'ASC');
        return count($this->db->get()->result_array());
    }
}
?>
